<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>微信小程序图标生成器</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
            background: #f5f5f5;
        }
        .container {
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        .icon-preview {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
            gap: 20px;
            margin: 20px 0;
        }
        .icon-item {
            text-align: center;
            padding: 15px;
            border: 1px solid #ddd;
            border-radius: 8px;
            background: white;
        }
        canvas {
            border: 1px solid #ccc;
            border-radius: 4px;
            margin: 10px 0;
        }
        .download-btn {
            background: #8B5CF6;
            color: white;
            border: none;
            padding: 8px 16px;
            border-radius: 4px;
            cursor: pointer;
            margin: 5px;
        }
        .download-btn:hover {
            background: #7C3AED;
        }
        .instructions {
            background: #E0E7FF;
            padding: 15px;
            border-radius: 8px;
            margin: 20px 0;
            border-left: 4px solid #8B5CF6;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>微信小程序图标生成器</h1>
        
        <div class="instructions">
            <h3>使用说明：</h3>
            <p>1. 点击下方的"生成图标"按钮生成所有图标</p>
            <p>2. 点击"下载"按钮保存对应的PNG文件</p>
            <p>3. 将下载的PNG文件放入项目的 <code>images/</code> 文件夹中</p>
            <p>4. 图标尺寸：81x81像素（微信小程序推荐尺寸）</p>
        </div>

        <button onclick="generateAllIcons()" class="download-btn">生成所有图标</button>

        <div class="icon-preview">
            <div class="icon-item">
                <h4>首页图标</h4>
                <canvas id="homeCanvas" width="81" height="81"></canvas>
                <br>
                <button onclick="downloadIcon('homeCanvas', 'home.png')" class="download-btn">下载 home.png</button>
            </div>

            <div class="icon-item">
                <h4>首页激活图标</h4>
                <canvas id="homeActiveCanvas" width="81" height="81"></canvas>
                <br>
                <button onclick="downloadIcon('homeActiveCanvas', 'home-active.png')" class="download-btn">下载 home-active.png</button>
            </div>

            <div class="icon-item">
                <h4>订单图标</h4>
                <canvas id="orderCanvas" width="81" height="81"></canvas>
                <br>
                <button onclick="downloadIcon('orderCanvas', 'order.png')" class="download-btn">下载 order.png</button>
            </div>

            <div class="icon-item">
                <h4>订单激活图标</h4>
                <canvas id="orderActiveCanvas" width="81" height="81"></canvas>
                <br>
                <button onclick="downloadIcon('orderActiveCanvas', 'order-active.png')" class="download-btn">下载 order-active.png</button>
            </div>

            <div class="icon-item">
                <h4>我的图标</h4>
                <canvas id="profileCanvas" width="81" height="81"></canvas>
                <br>
                <button onclick="downloadIcon('profileCanvas', 'profile.png')" class="download-btn">下载 profile.png</button>
            </div>

            <div class="icon-item">
                <h4>我的激活图标</h4>
                <canvas id="profileActiveCanvas" width="81" height="81"></canvas>
                <br>
                <button onclick="downloadIcon('profileActiveCanvas', 'profile-active.png')" class="download-btn">下载 profile-active.png</button>
            </div>
        </div>
    </div>

    <script>
        function generateAllIcons() {
            generateIcon('homeCanvas', '🏠', '#9CA3AF', '#FFFFFF');
            generateIcon('homeActiveCanvas', '🏠', '#8B5CF6', '#FFFFFF');
            generateIcon('orderCanvas', '📋', '#9CA3AF', '#FFFFFF');
            generateIcon('orderActiveCanvas', '📋', '#8B5CF6', '#FFFFFF');
            generateIcon('profileCanvas', '👤', '#9CA3AF', '#FFFFFF');
            generateIcon('profileActiveCanvas', '👤', '#8B5CF6', '#FFFFFF');
        }

        function generateIcon(canvasId, emoji, color, bgColor) {
            const canvas = document.getElementById(canvasId);
            const ctx = canvas.getContext('2d');
            
            // 清空画布
            ctx.clearRect(0, 0, 81, 81);
            
            // 绘制背景
            ctx.fillStyle = bgColor;
            ctx.fillRect(0, 0, 81, 81);
            
            // 绘制圆形背景
            ctx.fillStyle = color;
            ctx.beginPath();
            ctx.arc(40.5, 40.5, 30, 0, 2 * Math.PI);
            ctx.fill();
            
            // 绘制emoji
            ctx.font = '40px Arial';
            ctx.textAlign = 'center';
            ctx.textBaseline = 'middle';
            ctx.fillStyle = bgColor;
            ctx.fillText(emoji, 40.5, 40.5);
        }

        function downloadIcon(canvasId, filename) {
            const canvas = document.getElementById(canvasId);
            const link = document.createElement('a');
            link.download = filename;
            link.href = canvas.toDataURL('image/png');
            link.click();
        }

        // 页面加载时自动生成图标
        window.onload = function() {
            generateAllIcons();
        };
    </script>
</body>
</html>
